<template>
    <el-dialog
        :center="true"
        :show-close="false"
        :visible="show"
        @close="close"
        lock-scroll
        title="机构注册">
        <el-form label-width="80px">
            <el-form-item class="marginBottom" label="机构名称" prop="name">
                <el-input class="borderNone" clearable placeholder="机构名称" v-model="sub.name"></el-input>
            </el-form-item>
            <el-form-item class="marginBottom" label="邮箱" prop="email">
                <el-input class="borderNone" clearable placeholder="邮箱" v-model="sub.email"></el-input>
            </el-form-item>
            <el-form-item class="marginBottom" label="联系方式" prop="phone">
                <el-input class="borderNone" clearable placeholder="联系方式" v-model="sub.phone"></el-input>
            </el-form-item>
            <el-form-item class="marginBottom" label="备注" prop="remarks">
                <el-input class="borderNone" clearable placeholder="备注" v-model="sub.remarks"></el-input>
            </el-form-item>
<!--            <el-form-item class="marginBottom" label="类型" prop="type">-->
<!--                <el-select v-model="sub.type" placeholder="请选择">-->
<!--                    <el-option v-for="item in msgData" :key="item.id" :label="item.label" :value="item.id"></el-option>-->
<!--                </el-select>-->
<!--            </el-form-item>-->
            <el-form-item class="marginBottom">
                <el-button @click="submit" type="primary">提交申请</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script>
    export default {
        name: "index",
        props : {
          show : {
              type : Boolean,
              default : false,
          },
          userId : {
              type : Number,
          }
        },
        data(){
            return {
                sub : {
                    name : "",
                    remarks: "",
                    type: "",
                    email:"",
                    phone:"",
                    // 所属用户
                    userId: this.userId,
                    createDate :new Date().toLocaleDateString(),
                },
                // msgData : [
                //     {id : 1 , label : "公告"},
                //     {id : 2 , label : "校园资讯"},
                //     {id : 3 , label : "寻物启事"},
                //     {id : 4 , label : "其他"},
                // ]
            }
        },
        methods : {
            submit(){
                this.$api.office.officeAdd(this.sub)
                    .then(response => {
                        console.log(response);
                        this.$message({
                            message : "添加成功",
                            type : "success"
                        });
                        this.close();
                    })
                    .catch(error => {
                        this.$message.error("添加失败!");
                        console.log(error)
                    })
            },
            close(){
                this.$emit("close");
            }
        }
    }
</script>

<style scoped>

</style>
